package cate.game.role.res.worldtree.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDObj;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBWorldTree;
import cate.game.notice.msg.NoticeDialogResp;
import cate.game.res.RewardShow;
import cate.game.role.bag.hero.Hero;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "移除 英雄  共享の 请求")
@OperationSetter(GDOperation.WORLD_TREE_DEL_SHARE)
public class HeroShareDelReq implements MsgInput {
    @NoteField(value = "共享英雄背包位置", detail = "共享英雄背包位置")
    public int pos;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        GameResult<Hero> rr = cc.getRole().getRes().worldTree.heroShare.delHeroShare(pos);
        if (rr.ok()) {
            Hero hero = rr.data;
            RewardShow show = hero.offSthByLevel(game);
            show.addInsRwd(GDObj.Type.HERO, hero.uid);
            cc.getRole().getGame().notice.dialog(cc.getRole(), NoticeDialogResp.TYPE_REWARD, "恭喜获得",0, null, show.insRwd);
            cc.getRole().getRes().worldTree.heroShare.update2ClientByOnlyId(hero.uid);
            cc.sendNow(new HeroShareDelResp(pos, hero.uid, hero));
            cc.getRole().getBase().updatePower();
            cc.sendNow(new HeroShareDataResp(cc.getRole().getRes().worldTree.heroShare));
        } else {
            game.notice.message(cc.getRole(), rr.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBWorldTree.DEL_SHARE_REQ;
    }
}
